import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
  plugins: [vue()],
  server: {
    port: 3000,
    open: true,
    proxy: {
      '/api/gmgn': {
        target: 'https://gmgn.ai',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api\/gmgn/, '/vas/api/v1'),
        timeout: 60000,
        configure: (proxy, options) => {
          proxy.on('error', (err, req, res) => {
            console.log('代理错误:', err);
          });
          proxy.on('proxyReq', (proxyReq, req, res) => {
            console.log('发送请求到:', proxyReq.getHeader('host') + proxyReq.path);
          });
        }
      }
    }
  }
})
